package com.next

class BootStrap
{
    def init = { servletContext ->

        if (Role.count() < 1)
        {
            println 'init role data'

            def r = new Role()
            r.authority = 'ROLE_ADMINISTRATOR'
            r.description = '系统管理员'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_ACCOUNT_MANAGER'
            r.description = '客户经理'
            r.save flush: true

            // r = new Role()
            // r.authority = 'ROLE_COMPANY_ADMINISTRATOR'
            // r.description = '机构管理员'
            // r.save flush: true

            // r = new Role()
            // r.authority = 'ROLE_AGENT'
            // r.description = '经纪人'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_CUSTOMER'
            // r.description = '客户'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_PRODUCT_ADMINISTRATOR'
            // r.description = '产品管理员'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_GENERAL_RISK_MANAGER'
            // r.description = '风控总经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_BRANCH_OFFICE_RISK_MANAGER'
            // r.description = '分公司风控经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_HEAD_OFFICE_RISK_MANAGER'
            // r.description = '总部风控经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_GENERAL_MANAGER'
            // r.description = '业务总经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_CRO'
            // r.description = 'CRO'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_CEO'
            // r.description = 'CEO'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_COO'
            // r.description = 'COO'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_HR_MANAGER'
            // r.description = '人员资源经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_POST_LOAN_MANAGER'
            // r.description = '贷后经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_COMPLIANCE_MANAGER'
            // r.description = '合规则经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_BRANCH_GENERAL_MANAGER'
            // r.description = '区域总经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_BRANCH_OFFICE_POST_LOAN_MANAGER'
            // r.description = '区域贷后经理'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_CUSTOMER_SERVICE_REPRESENTATIVE'
            // r.description = '客服专员'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_BRANCH_OFFICE_CASHIER'
            // r.description = '区域出纳'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'SALES_REPRESENTATIVE'
            // r.description = '销售'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_INVESTOR'
            // r.description = '投资人'
            // r.save flush: true
            //
            // r = new Role()
            // r.authority = 'ROLE_CONDITION_RULEENGINE'
            // r.description = '规则引擎'
            // r.save flush: true
        }

        if (Role.count() == 2)
        {
            def r = new Role()
            r.authority = 'ROLE_HEAD_OFFICE_ADMINISTRATOR'
            r.description = '总行管理员'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_PROVINCE_BRANCH_OFFICE_ADMINISTRATOR'
            r.description = '省分行管理员'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_PROVINCE_BRANCH_OFFICE_PRODUCT_MANAGER'
            r.description = '省行产品经理'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_SECOND_BRANCH_OFFICE_PRODUCT_MANAGER'
            r.description = '二级分行产品经理'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_SECOND_BRANCH_OFFICE_DIRECTOR'
            r.description = '二级分行主管'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_SALES_REPRESENTATIVE'
            r.description = '销售'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_BANK_OUTLETS_ADMINISTRATOR'
            r.description = '网点管理员'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_MERCHANT_ADMINISTRATOR'
            r.description = '商户管理员'
            r.save flush: true

            r = new Role()
            r.authority = 'ROLE_CHANNEL_ADMINISTRATOR'
            r.description = '渠道管理员'
            r.save flush: true
        }

        if (AccountType.count() < 1)
        {
            println "init accountType"
            def type = new AccountType(name: "Partner")
            type.save flush: true

            type = new AccountType(name: "Broker Office")
            type.save flush: true

            type = new AccountType(name: "Department")
            type.save flush: true

            type = new AccountType(name: "机构")
            type.save flush: true

            type = new AccountType(name: "渠道")
            type.save flush: true

            type = new AccountType(name: "商户")
            type.save flush: true
        }

        if (Account.count() < 1)
        {
            println "init account"
            def c = new Account(name: "Default", code: "cdae403a-c468-49ee-b68d-b40b4807e55b", type: AccountType.findByName("Partner"), externalId: 'default-1')
            c.save flush: true
        }

        if (User.count() < 1)
        {
            println 'init user data'

            def account = Account.findByName("Default")
            def c = new User()
            c.username = 'administrator'
            c.password = 'C7ISJ4e&i1nVPXUz'
            c.fullName = "管理员"
            c.cellphone = "18513603065"
            c.account = account
            c.save flush: true

            account = Account.findByName("Default")
            c = new User()
            c.username = 'lyky'
            c.password = '1ykDLQUeAqkF$vRw'
            c.fullName = "测试账号"
            c.cellphone = "18811432134"
            c.account = account
            c.position = Position.findByName("销售员")
            c.save flush: true
        }

        if (UserRole.count() < 1)
        {
            println 'init user role data'

            UserRole.create(User.findByUsername('administrator'), Role.findByAuthority('ROLE_ADMINISTRATOR'))
            UserRole.create(User.findByUsername('lyky'), Role.findByAuthority('ROLE_ACCOUNT_MANAGER'))
        }

        if (Department.count() < 1)
        {
            println "init department"
            def d = new Department()
            d.name = "支持组"
            d.save flush: true

            d = new Department()
            d.name = "风控组"
            d.save flush: true

            d = new Department()
            d.name = "权证组"
            d.save flush: true

            d = new Department()
            d.name = "销售组"
            d.save flush: true

            d = new Department()
            d.name = "财务组"
            d.save flush: true

            d = new Department()
            d.name = "下户组"
            d.save flush: true
        }

        if (Position.count() < 1)
        {
            println "init position"
            def position = new Position(name: "销售经理")
            position.save flush: true

            // position = new Position(name: "销售主管")
            // position.save flush: true
            //
            // position = new Position(name: "销售员")
            // position.save flush: true
            //
            // position = new Position(name: "销售支持主管")
            // position.save flush: true
            //
            // position = new Position(name: "销售支持专员")
            // position.save flush: true
            //
            // position = new Position(name: "风控经理")
            // position.save flush: true
            //
            // position = new Position(name: "风控主单")
            // position.save flush: true
            //
            // position = new Position(name: "风控初审")
            // position.save flush: true
            //
            // position = new Position(name: "外访专员")
            // position.save flush: true
            //
            // position = new Position(name: "风控助理")
            // position.save flush: true
            //
            // position = new Position(name: "权证经理")
            // position.save flush: true
            //
            // position = new Position(name: "高级权证专员")
            // position.save flush: true
            //
            // position = new Position(name: "权证专员")
            // position.save flush: true
            //
            // position = new Position(name: "调派员")
            // position.save flush: true
            //
            // position = new Position(name: "资料取送专员")
            // position.save flush: true
            //
            // position = new Position(name: "总经理")
            // position.save flush: true
            //
            // position = new Position(name: "财务经理")
            // position.save flush: true
            //
            // position = new Position(name: "财务主管")
            // position.save flush: true
            //
            // position = new Position(name: "行政经理")
            // position.save flush: true
            //
            // position = new Position(name: "下户专员")
            // position.save flush: true
            //
            // position = new Position(name: "风控总经理")
            // position.save flush: true
            //
            // position = new Position(name: "分公司风控经理")
            // position.save flush: true
            //
            // position = new Position(name: "总部风控经理")
            // position.save flush: true
            //
            // position = new Position(name: "业务总经理")
            // position.save flush: true
            //
            // position = new Position(name: "CRO")
            // position.save flush: true
            //
            // position = new Position(name: "CEO")
            // position.save flush: true

        }

        if (Territory.count() < 1)
        {
            println "init territory"
            def t = new Territory(name: "默认区域")

            t.inheritTeam = false

            t.save flush: true
        }

        if (Province.count() < 1)
        {
            println "init province"
            def p = new Province(name: "北京")

            p.save flush: true
        }

        if (City.count() < 1)
        {
            println "init city"
            def d = new City()
            d.name = "北京"
            d.province = Province.findByName("北京")
            d.telephone = "4008882006"
            d.save flush: true
        }

        if (OpportunityType.count() < 1)
        {
            println "init opportunityType"
            def type = new OpportunityType(code: '10', name: '抵押贷款')
            type.save flush: true

            type = new OpportunityType(code: '20', name: '抵押贷款展期')
            type.save flush: true

            type = new OpportunityType(code: '01', name: '信用贷款')
            type.save flush: true

            type = new OpportunityType(code: '02', name: '企业贷款')
            type.save flush: true

            type = new OpportunityType(code: '03', name: '车贷')
            type.save flush: true
        }

        if (OpportunitySubtype.count() < 1)
        {
            println "init opportunitySubType"
            def type = OpportunityType.findByName('抵押贷款')

            def subType = new OpportunitySubtype(name: '正常审批')
            subType.type = type
            subType.save flush: true

            subType = new OpportunitySubtype(name: '特殊审批')
            subType.type = type
            subType.save flush: true
        }

        if (ContactLevel.count() < 1)
        {
            println "init contactLevel"
            def level = new ContactLevel()
            level.name = "A"
            level.description = "优质"
            level.save flush: true

            level = new ContactLevel()
            level.name = "B"
            level.description = "在京二套房产证明；理财协议；股票市值截屏；股票市值截屏；流水、网银截屏；上下游合同；应收账款；行驶证；外地房产；大额存单，包括但不限于以上资料。面审时请至少携带其中一件。"
            level.save flush: true

            level = new ContactLevel()
            level.name = "C"
            level.description = "疑难客户"
            level.save flush: true

            level = new ContactLevel()
            level.name = "D"
            level.description = "不良客户"
            level.save flush: true
        }

        if (CauseOfFailure.count() < 1)
        {
            println "init causeOfFailure"
            def cf = new CauseOfFailure()
            cf.name = "评估值不够"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "二抵剩余残值不够"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "考虑中"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "风控降成"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "我司不受理"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "超过公司单笔贷款金额"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "息费高"
            cf.save flush: true
            cf = new CauseOfFailure()
            cf.name = "贷款手续麻烦"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "资金问题已解决（非同行）"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "在同行已成交"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "房本被占用"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "只办理0.6%的业务"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "客户需求不明确"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "客户要求市值的七成"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "正在补资料"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "家人不同意"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "客户资质不够"
            cf.save flush: true

            cf = new CauseOfFailure()
            cf.name = "超时"
            cf.save flush: true
        }

        if (TeamRole.count() < 1)
        {
            println "init teamRole"
            def tr = new TeamRole(name: "Read")
            tr.save flush: true

            tr = new TeamRole(name: "Edit")
            tr.save flush: true

            tr = new TeamRole(name: "Administrator")
            tr.save flush: true

            tr = new TeamRole(name: "Approval")
            tr.save flush: true
        }

        if (OpportunityContactType.count() < 1)
        {
            println "init opportunityContactType"
            def type = new OpportunityContactType(name: "借款人")
            type.save flush: true

            type = new OpportunityContactType(name: "借款人配偶")
            type.save flush: true

            type = new OpportunityContactType(name: "抵押人")
            type.save flush: true

            type = new OpportunityContactType(name: "抵押人配偶")
            type.save flush: true

            type = new OpportunityContactType(name: "其它借款人")
            type.save flush: true

            type = new OpportunityContactType(name: "借款人父母")
            type.save flush: true

            type = new OpportunityContactType(name: "借款人子女")
            type.save flush: true

            type = new OpportunityContactType(name: "联系人")
            type.save flush: true
        }

        if (InterestPaymentMethod.count() < 1)
        {
            println "init interestPaymentMethod"
            def ipm = new InterestPaymentMethod(name: "扣息差")
            ipm.save flush: true

            ipm = new InterestPaymentMethod(name: "上扣息")
            ipm.save flush: true

            ipm = new InterestPaymentMethod(name: "一次性付息")
            ipm.save flush: true

            ipm = new InterestPaymentMethod(name: "等本等息")
            ipm.save flush: true
        }

        if (CommissionPaymentMethod.count() < 1)
        {
            println "init commissionPaymentMethod"
            def cycle = new CommissionPaymentMethod(name: "月月返")
            cycle.save flush: true

            cycle = new CommissionPaymentMethod(name: "一次性返")
            cycle.save flush: true
        }

        if (AttachmentType.count() < 1)
        {
            println "init attachmentType"
            def at = new AttachmentType(name: "房产证")
            at.save flush: true

            at = new AttachmentType(name: "征信授权")
            at.save flush: true

            at = new AttachmentType(name: "借款人身份证")
            at.save flush: true

            at = new AttachmentType(name: "借款人配偶身份证")
            at.save flush: true

            at = new AttachmentType(name: "抵押人身份证")
            at.save flush: true

            at = new AttachmentType(name: "抵押人配偶身份证")
            at.save flush: true

            at = new AttachmentType(name: "购房合同")
            at.save flush: true

            at = new AttachmentType(name: "出租：抵押物租赁合同、租客告知书")
            at.save flush: true

            at = new AttachmentType(name: "二抵：抵押物银行按揭贷款合同")
            at.save flush: true

            at = new AttachmentType(name: "特殊房产需提供资料")
            at.save flush: true

            at = new AttachmentType(name: "小区外围配套物业")
            at.save flush: true

            at = new AttachmentType(name: "出入口道路")
            at.save flush: true

            at = new AttachmentType(name: "小区名称及物业地址")
            at.save flush: true

            at = new AttachmentType(name: "小区楼栋号、单元号、门牌号")
            at.save flush: true

            //小区规模（由卧室或阳台拍摄小区俯瞰图）
            at = new AttachmentType(name: "小区规模")
            at.save flush: true

            at = new AttachmentType(name: "抵押物各房间情况")
            at.save flush: true

            at = new AttachmentType(name: "家访人员出镜照片")
            at.save flush: true

            at = new AttachmentType(name: "客户出镜的照片")
            at.save flush: true

            at = new AttachmentType(name: "户口本（集体户口需提供额外资料）")
            at.save flush: true

            at = new AttachmentType(name: "特殊资料")
            at.save flush: true

            at = new AttachmentType(name: "附加资料")
            at.save flush: true

            at = new AttachmentType(name: "产调结果")
            at.save flush: true

            at = new AttachmentType(name: "征信报告")
            at.save flush: true

            at = new AttachmentType(name: "征信查询授权书")
            at.save flush: true

            at = new AttachmentType(name: "返点证明")
            at.save flush: true

            at = new AttachmentType(name: "放款证明")
            at.save flush: true

            at = new AttachmentType(name: "他项证明")
            at.save flush: true

            at = new AttachmentType(name: "公证书")
            at.save flush: true

            at = new AttachmentType(name: "签约合同")
            at.save flush: true

            at = new AttachmentType(name: "估值附回材料")
            at.save flush: true

            // at = new AttachmentType(name: "面谈笔录")
            // at.save flush:true

            at = new AttachmentType(name: "被执情况")
            at.save flush: true

            at = new AttachmentType(name: "户口本")
            at.save flush: true

            at = new AttachmentType(name: "婚姻证明")
            at.save flush: true

            at = new AttachmentType(name: "大数据")
            at.save flush: true

            at = new AttachmentType(name: "风险调查报告")
            at.save flush: true

            at = new AttachmentType(name: "抵押公证受理单")
            at.save flush: true

            at = new AttachmentType(name: "驾驶证")
            at.save flush: true

            at = new AttachmentType(name: "车辆评估证明")
            at.save flush: true

            at = new AttachmentType(name: "购车合同")
            at.save flush: true

            at = new AttachmentType(name: "行驶证")
            at.save flush: true

            at = new AttachmentType(name: "强执公证")
            at.save flush: true

            at = new AttachmentType(name: "售房公证")
            at.save flush: true

            at = new AttachmentType(name: "特批签呈")
            at.save flush: true

            at = new AttachmentType(name: "普通签呈")
            at.save flush: true

            at = new AttachmentType(name: "营业执照")
            at.save flush: true

            at = new AttachmentType(name: "行驶本")
            at.save flush: true

            at = new AttachmentType(name: "驾驶证")
            at.save flush: true

            at = new AttachmentType(name: "行驶证")
            at.save flush: true

            at = new AttachmentType(name: "行驶证")
            at.save flush: true

            at = new AttachmentType(name: "购车合同")
            at.save flush: true

            at = new AttachmentType(name: "车辆评估证明")
            at.save flush: true

            at = new AttachmentType(name: "组织机构代码")
            at.save flush: true

            at = new AttachmentType(name: "税务登记证")
            at.save flush: true

            at = new AttachmentType(name: "财务报表")
            at.save flush: true

            at = new AttachmentType(name: "身份证")
            at.save flush: true

            at = new AttachmentType(name: "婚姻证明")
            at.save flush: true

            at = new AttachmentType(name: "担保人资料")
            at.save flush: true

            at = new AttachmentType(name: "股东会同意贷款的决议")
            at.save flush: true

            at = new AttachmentType(name: "税务登记证明")
            at.save flush: true

            at = new AttachmentType(name: "开户许可证")
            at.save flush: true

            at = new AttachmentType(name: "公司章程")
            at.save flush: true

            at = new AttachmentType(name: "验资报告")
            at.save flush: true

            at = new AttachmentType(name: "场地经营相关资料")
            at.save flush: true

            at = new AttachmentType(name: "收入资料证明")
            at.save flush: true

            at = new AttachmentType(name: "财务报表")
            at.save flush: true
        }

        if (!AttachmentType.findByName("面签"))
        {
            def at = new AttachmentType(name: "面签")
            at.save flush: true
        }
        if (!AttachmentType.findByName("划付授权书"))
        {
            def at = new AttachmentType(name: "划付授权书")
            at.save flush: true
        }
        if (!AttachmentType.findByName("分期业务合同协议"))
        {
            def at = new AttachmentType(name: "分期业务合同协议")
            at.save flush: true
        }
        if (!AttachmentType.findByName("分期业务告知书"))
        {
            def at = new AttachmentType(name: "分期业务告知书")
            at.save flush: true
        }
        if (!AttachmentType.findByName("购车发票"))
        {
            def at = new AttachmentType(name: "购车发票")
            at.save flush: true
        }
        if (!AttachmentType.findByName("商业险保单"))
        {
            def at = new AttachmentType(name: "商业险保单")
            at.save flush: true
        }
        if (!AttachmentType.findByName("购置税完税证明"))
        {
            def at = new AttachmentType(name: "购置税完税证明")
            at.save flush: true
        }
        if (!AttachmentType.findByName("借款人身份证正面"))
        {
            def at = new AttachmentType(name: "借款人身份证正面")
            at.save flush: true
            at = new AttachmentType(name: "借款人身份证反面")
            at.save flush: true
            at = new AttachmentType(name: "借款人配偶身份证正面")
            at.save flush: true
            at = new AttachmentType(name: "借款人配偶身份证反面")
            at.save flush: true
        }

        if (AddressType.count() < 1)
        {
            println "init addressType"
            def type = new AddressType(name: "建委")
            type.save flush: true

            type = new AddressType(name: "公证处")
            type.save flush: true
        }

        if (AssetType.count() < 1)
        {
            println "init assetType"
            def at = new AssetType(name: "住宅")
            at.save flush: true

            at = new AssetType(name: "商品房")
            at.save flush: true

            at = new AssetType(name: "央产房")
            at.save flush: true

            at = new AssetType(name: "经济适用房")
            at.save flush: true

            at = new AssetType(name: "按经济适用房管理")
            at.save flush: true

            at = new AssetType(name: "优惠价房改房")
            at.save flush: true

            at = new AssetType(name: "标准价房改房")
            at.save flush: true

            at = new AssetType(name: "回迁房")
            at.save flush: true

            at = new AssetType(name: "军产房")
            at.save flush: true

            at = new AssetType(name: "校产房")
            at.save flush: true

            at = new AssetType(name: "其他")
            at.save flush: true

            at = new AssetType(name: "成本价房改房")
            at.save flush: true

            at = new AssetType(name: "商业办公")
            at.save flush: true

            at = new AssetType(name: "房改房")
            at.save flush: true

            at = new AssetType(name: "未知")
            at.save flush: true

            at = new AssetType(name: "公寓")
            at.save flush: true

            at = new AssetType(name: "别墅")
            at.save flush: true

            at = new AssetType(name: "限价房")
            at.save flush: true
        }

        if (TypeOfFirstMortgage.count() < 1)
        {
            println "init typeOfFirstMortgage"
            def t = new TypeOfFirstMortgage(name: "银行类")
            t.save flush: true

            t = new TypeOfFirstMortgage(name: "非银行类")
            t.save flush: true
        }

        if (HouseType.count() < 1)
        {
            println "init houseType"
            def t = new HouseType(name: "普通住宅")
            t.save flush: true
            t = new HouseType(name: "独栋")
            t.save flush: true
            t = new HouseType(name: "联排")
            t.save flush: true
            t = new HouseType(name: "双拼")
            t.save flush: true
            t = new HouseType(name: "叠拼")
            t.save flush: true
            t = new HouseType(name: "独栋别墅")
            t.save flush: true
            t = new HouseType(name: "联排别墅")
            t.save flush: true
            t = new HouseType(name: "双拼别墅")
            t.save flush: true
            t = new HouseType(name: "叠拼别墅")
            t.save flush: true
            t = new HouseType(name: "商业")
            t.save flush: true
            t = new HouseType(name: "办公")
            t.save flush: true
            t = new HouseType(name: "公寓")
            t.save flush: true
            t = new HouseType(name: "未知")
            t.save flush: true
            t = new HouseType(name: "其他")
            t.save flush: true

        }

        if (SpecialFactors.count() < 1)
        {
            println "init specialFactors"
            def sf = new SpecialFactors(name: "无")
            sf.save flush: true

            sf = new SpecialFactors(name: "复式")
            sf.save flush: true

            sf = new SpecialFactors(name: "LOFT")
            sf.save flush: true

            sf = new SpecialFactors(name: "跃层")
            sf.save flush: true

            sf = new SpecialFactors(name: "一层赠送")
            sf.save flush: true

            sf = new SpecialFactors(name: "临湖")
            sf.save flush: true

            sf = new SpecialFactors(name: "楼王")
            sf.save flush: true

            sf = new SpecialFactors(name: "临街")
            sf.save flush: true
        }

        if (MortgageType.count() < 1)
        {
            println "init mortgageType"
            def t = new MortgageType(name: "一抵")
            t.save flush: true

            t = new MortgageType(name: "二抵")
            t.save flush: true

            t = new MortgageType(name: "一抵转单")
            t.save flush: true

            t = new MortgageType(name: "二抵转单")
            t.save flush: true
        }

        if (ActivityType.count() < 1)
        {
            println "init activityType"
            def type = new ActivityType(name: "Appointment")
            type.save flush: true

            type = new ActivityType(name: "Task")
            type.save flush: true

            type = new ActivityType(name: "Call")
            type.save flush: true
        }

        if (ActivitySubtype.count() < 1)
        {
            println "init activitySubtype"
            def subtype = new ActivitySubtype(name: "下户", type: ActivityType.findByName("Appointment"))
            subtype.save flush: true

            subtype = new ActivitySubtype(name: "抵押", type: ActivityType.findByName("Appointment"))
            subtype.save flush: true

            subtype = new ActivitySubtype(name: "公正", type: ActivityType.findByName("Appointment"))
            subtype.save flush: true

            subtype = new ActivitySubtype(name: "面审", type: ActivityType.findByName("Appointment"))
            subtype.save flush: true

            subtype = new ActivitySubtype(name: "Sign In", type: ActivityType.findByName("Call"))
            subtype.save flush: true

            subtype = new ActivitySubtype(name: "产调", type: ActivityType.findByName("Appointment"))
            subtype.save flush: true
        }

        if (CreditReportProvider.count() < 1)
        {
            println "init creditReportProvider"
            def p = new CreditReportProvider(code: "TONGDUN", name: "同盾", apiUrl: "http://10.0.8.101/tongdun-2.0" + "/provider/evaluate2")
            p.save flush: true

            p = new CreditReportProvider(code: "BAIRONG", name: "百融", apiUrl: "http://10.0.8.102/bairong-1.0" + ".0/provider/evaluate2")
            p.save flush: true

            p = new CreditReportProvider(code: "HUIFA", name: "汇法", apiUrl: "http://10.0.8.136:8080/huifa-1.0" + "/provider/evaluate2")
            p.save flush: true
        }

        if (MessageTemplate.count() < 1)
        {
            println "init messageTemplate"
            def message = new MessageTemplate(text: "【客户端】您的经纪人 contactName （contactCellphone） 有评房成功订单（serialNumber），请及时关注跟进！")
            message.save flush: true

            message = new MessageTemplate(text: "【客户端】您的经纪人 contactName（contactCellphone）已提交报单，请及时提供身份证、房产证图片，敬请配合，感谢！")
            message.save flush: true

            message = new MessageTemplate(text: "【客户端】您的经纪人 contactName （contactCellphone） 已提交报单，请及时关注跟进！")
            message.save flush: true

            message = new MessageTemplate(text: "【客户端】订单serialNumber（stage）已分配至您处，请及时处理！")
            message.save flush: true

            message = new MessageTemplate(text: "【客户端】您的订单（serialNumber）已失败，失败原因为：causeOfFailure。")
            message.save flush: true

        }

        if (PropertyValuationProvider.count() < 1)
        {
            println "init propertyValuationProvider"
            def provider = new PropertyValuationProvider(code: "FGG", name: "房估估", apiUrl: "http://10.0.8.104/fgg-1.0" + ".0/provider/evaluate")
            provider.save flush: true

            provider = new PropertyValuationProvider(code: "VISS", name: "中估联", apiUrl: "http://10.0.8.103/viss-1.0" + ".0/provider/evaluate")
            provider.save flush: true
        }

        if (CityPropertyValuationProvider.count() < 1)
        {
            println "init cityPropertyValuationProvider"
            def cp = new CityPropertyValuationProvider()
            cp.provider = PropertyValuationProvider.findByCode("FGG")
            cp.city = City.findByName("北京")
            cp.save flush: true
        }

        if (District.count() < 1)
        {
            println "init district"
            def district = new District()
            district.name = "朝阳区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "东城区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "西城区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "丰台区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "石景山区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "海淀区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "大兴区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "通州区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "昌平区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "房山区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "顺义区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "怀柔区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "密云县"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "平谷区"
            district.city = City.findByName("北京")
            district.save flush: true

            district = new District()
            district.name = "延庆县"
            district.city = City.findByName("北京")
            district.save flush: true
        }

        if (AppVersion.count() < 1)
        {
            println "init appVersion"
            def appVersion = new AppVersion(appName: 'client-ios', appVersion: '1.0', description: '第一个版本')
            appVersion.save flush: true
        }

        if (ProductInterestType.count() < 1)
        {
            println "init productInterestType"
            def type = new ProductInterestType(name: '基本费率', isUsed: true)
            type.save flush: true

            type = new ProductInterestType(name: '服务费费率', isUsed: true)
            type.save flush: true

            type = new ProductInterestType(name: '渠道返费费率', isUsed: true)
            type.save flush: true

            type = new ProductInterestType(name: '二抵加收费率', isUsed: true)
            type.save flush: true

            type = new ProductInterestType(name: '信用调整', isUsed: true)
            type.save flush: true
        }

        if (BillsItemType.count() < 1)
        {
            println "init billsItemType"
            def type = new BillsItemType(name: '基本费率')
            type.save flush: true

            type = new BillsItemType(name: '服务费费率')
            type.save flush: true

            type = new BillsItemType(name: '渠道返费费率')
            type.save flush: true

            type = new BillsItemType(name: '二抵加收费率')
            type.save flush: true

            type = new BillsItemType(name: '信用调整')
            type.save flush: true

            type = new BillsItemType(name: '本金')
            type.save flush: true

            type = new BillsItemType(name: '郊县')
            type.save flush: true

            type = new BillsItemType(name: '大头小尾')
            type.save flush: true

            type = new BillsItemType(name: '老人房（65周岁以上）')
            type.save flush: true

            type = new BillsItemType(name: '意向金')
            type.save flush: true
        }

        if (PrincipalPaymentMethod.count() < 1)
        {
            println "init principalPaymentMethod"
            def ppm = new PrincipalPaymentMethod(name: "按月等额本金还款")
            ppm.save flush: true

            ppm = new PrincipalPaymentMethod(name: "到期一次性还本")
            ppm.save flush: true

            // ppm = new PrincipalPaymentMethod(name: "等本等息")
            // ppm.save flush: true

            // ppm = new PrincipalPaymentMethod(name: "气球贷（60期）")
            // ppm.save flush: true

            // ppm = new PrincipalPaymentMethod(name: "气球贷（120期）")
            // ppm.save flush: true

            // ppm = new PrincipalPaymentMethod(name: "等额本息")
            // ppm.save flush: true
        }

        if (ProductCategory.count() < 1)
        {
            println "init productCategory"
            def productCategory = new ProductCategory(name: "抵押贷", maxinumAmount: 1000000)
            productCategory.save(flush: true)
            productCategory = new ProductCategory(name: "信用贷", maxinumAmount: 1000000)
            productCategory.save(flush: true)

            productCategory = new ProductCategory(name: "企业信用贷", maxinumAmount: 1000000)
            productCategory.save(flush: true)
        }

        ProductService productService = new ProductService()
        productService.initProduct()

        if (AppConfigurationKey.count() < 1)
        {
            println "init appConfigurationKey"
            def ak = new AppConfigurationKey(name: '北京邀请码')
            ak.save flush: true

            ak = new AppConfigurationKey(name: '合肥邀请码')
            ak.save flush: true
        }

        if (!AppConfigurationKey.findByName("appApproveStatus"))
        {
            println "init appConfigurationKey"
            def ak = new AppConfigurationKey(name: 'appApproveStatus')
            ak.save flush: true
        }

        if (LoanApplicationProcessType.count() < 1)
        {
            println "init loanApplicationProcessType"
            def type = new LoanApplicationProcessType(name: '直接报单')
            type.save flush: true

            type = new LoanApplicationProcessType(name: '先评房再报单')
            type.save flush: true
        }
        //        初始化flexFieldCategory
        FlexFieldCategoryService flexFieldCategoryService = new FlexFieldCategoryService()
        flexFieldCategoryService.initFlexFieldCategory

        if (MortgageCertificateType.count() < 1)
        {
            println "init mortgageCertificateType"
            def type = new MortgageCertificateType(name: '抵押受理单')
            type.save flush: true

            type = new MortgageCertificateType(name: '他项证明')
            type.save flush: true
        }

        if (OpportunityBankAccountType.count() < 1)
        {
            println "init opportunityBankAccountType"
            def type = new OpportunityBankAccountType(name: '收款账号')
            type.save flush: true

            type = new OpportunityBankAccountType(name: '还款账号')
            type.save flush: true
        }

        if (OpportunityLayout.count() < 1)
        {
            println "init opportunityLayout"
            def opportunityLayout = new OpportunityLayout(name: 'opportunityLayout01', description: '审批页')
            opportunityLayout.save flush: true
        }

        if (CollateralProjectType.count() < 1)
        {
            println "init collateralProjectType"
            def type = new CollateralProjectType(name: '住宅')
            type.save flush: true

            type = new CollateralProjectType(name: '别墅')
            type.save flush: true

            type = new CollateralProjectType(name: '商业')
            type.save flush: true

            type = new CollateralProjectType(name: '商住两用')
            type.save flush: true

            type = new CollateralProjectType(name: '其他')
            type.save flush: true
        }

        if (ContactProfession.count() < 1)
        {
            println "init contactProfession"
            def profession = new ContactProfession(name: '公检法从业人员')
            profession.save flush: true

            profession = new ContactProfession(name: '现役军人')
            profession.save flush: true

            profession = new ContactProfession(name: '金融同业的法人/股东/隐形股东')
            profession.save flush: true

            profession = new ContactProfession(name: '娱乐(KTV)的法人/股东/隐形股东')
            profession.save flush: true

            profession = new ContactProfession(name: '钢贸/煤炭(上下游)/有色金属的法人/股东/隐形股东')
            profession.save flush: true

            profession = new ContactProfession(name: '房地产开发/建筑公司(承接房地产开发项目的工程总包方)的法人/股东/隐形股东')
            profession.save flush: true

            profession = new ContactProfession(name: '其他职业')
            profession.save flush: true
        }

        if (Country.count() < 1)
        {
            println "init country"
            def country = new Country(name: '中国')
            country.save flush: true

            country = new Country(name: '台湾')
            country.save flush: true

            country = new Country(name: '香港')
            country.save flush: true

            country = new Country(name: '澳门')
            country.save flush: true

            country = new Country(name: '美国')
            country.save flush: true
        }

        if (ContactIdentityType.count() < 1)
        {
            println "init contactIdentityType"
            def type = new ContactIdentityType(name: '个人居民身份证')
            type.save flush: true

            type = new ContactIdentityType(name: '临时身份证')
            type.save flush: true

            type = new ContactIdentityType(name: '护照')
            type.save flush: true
        }

        if (BillsStatus.count() < 1)
        {
            println "init billsStatus"
            def status = new BillsStatus(name: '测算')
            status.save flush: true

            status = new BillsStatus(name: '还款中')
            status.save flush: true

            status = new BillsStatus(name: '已结清')
            status.save flush: true

            status = new BillsStatus(name: '逾期未处理')
            status.save flush: true

            status = new BillsStatus(name: '已展期')
            status.save flush: true

            status = new BillsStatus(name: '提前结清')
            status.save flush: true
        }

        if (BillsItemType.count() < 1)
        {
            println "init billsItemType"
            def type = new BillsItemType(name: '本金')
            type.save flush: true
        }

        if (OpportunityAction.count() < 1)
        {
            println "init opportunityAction"
            def action = new OpportunityAction(name: '同意')
            action.save flush: true

            action = new OpportunityAction(name: '不同意')
            action.save flush: true

            action = new OpportunityAction(name: '特批')
            action.save flush: true

            action = new OpportunityAction(name: '拒单')
            action.save flush: true
        }

        if (TransactionType.count() < 1)
        {
            println "init transactionType"
            def type = new TransactionType(name: '放款')
            type.save flush: true

            type = new TransactionType(name: '罚息')
            type.save flush: true

            type = new TransactionType(name: '还本')
            type.save flush: true

            type = new TransactionType(name: '还息')
            type.save flush: true
        }

        if (TransactionRecordStatus.count() < 1)
        {
            println "init transactionRecordStatus"
            def status = new TransactionRecordStatus(name: '未执行')
            status.save flush: true

            status = new TransactionRecordStatus(name: '已成功')
            status.save flush: true

            status = new TransactionRecordStatus(name: '已失败')
            status.save flush: true
        }

        if (CollateralRegion.count() < 1)
        {
            println "init collateralRegion"
            def region = new CollateralRegion(name: '二环内')
            region.save flush: true

            region = new CollateralRegion(name: '二环到三环之间')
            region.save flush: true

            region = new CollateralRegion(name: '三环到四环之间')
            region.save flush: true

            region = new CollateralRegion(name: '四环到五环之间')
            region.save flush: true

            region = new CollateralRegion(name: '五环到六环之间')
            region.save flush: true

            region = new CollateralRegion(name: '六环外')
            region.save flush: true
        }

        if (ExternalDataProvider.count() < 1)
        {
            println "init externalDataProvider"
            def provider = new ExternalDataProvider(name: '百融')
            provider.save flush: true

            provider = new ExternalDataProvider(name: '鹏元个人')
            provider.save flush: true

            provider = new ExternalDataProvider(name: '汇法')
            provider.save flush: true

            provider = new ExternalDataProvider(name: '同盾')
            provider.save flush: true

            provider = new ExternalDataProvider(name: '汇法企业')
            provider.save flush: true
        }

        if (ContractType.count() < 1)
        {
            println "init contractType"
            def contractType = new ContractType(name: '借款合同')
            contractType.save flush: true

            contractType = new ContractType(name: '抵押合同')
            contractType.save flush: true

            contractType = new ContractType(name: '委托借款代理服务合同')
            contractType.save flush: true

            contractType = new ContractType(name: '委托保证合同')
            contractType.save flush: true
        }

        if (ContractTemplate.count() < 1)
        {
            println "init comtractTemplate"
            def contractType = ContractType.findByName('借款合同')

            def contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-企业经营流动资金'
            contractTemplate.save flush: true
            def contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-新项目启动资金'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-偿还欠款'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-家庭生活消费'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-留学/移民'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-周转应急'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-赎楼'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-买房'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-买车'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true

            contractTemplate = new ContractTemplate(type: contractType)
            contractTemplate.name = '借款用途-其他'
            contractTemplate.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '否'
            contractTemplateOptions.displayOrder = 0
            contractTemplateOptions.save flush: true
            contractTemplateOptions = new ContractTemplateOptions(template: contractTemplate)
            contractTemplateOptions.value = '是'
            contractTemplateOptions.displayOrder = 1
            contractTemplateOptions.save flush: true
        }

        if (ComponentType.count() < 1)
        {
            println "init componentType"
            def type = new ComponentType(name: 'Condition')
            type.save flush: true

            type = new ComponentType(name: 'Event')
            type.save flush: true
        }

        if (ExternalDatasetType.count() < 1)
        {
            println "init externalDatasetType"
            def t = new ExternalDatasetType(name: '央行征信')
            t.save flush: true

            t = new ExternalDatasetType(name: '百融特殊名单核查')
            t.save flush: true

            t = new ExternalDatasetType(name: '百融个人不良信息查询高级版')
            t.save flush: true

            t = new ExternalDatasetType(name: '百融身份证核查')
            t.save flush: true
        }

        if (WorkflowInstanceStatus.count() < 1)
        {
            println "init WorkflowInstanceStatus"
            def w = new WorkflowInstanceStatus(name: 'Pending')
            w.save flush: true

            w = new WorkflowInstanceStatus(name: 'Completed')
            w.save flush: true

            w = new WorkflowInstanceStatus(name: 'Failed')
            w.save flush: true
        }

        if (WorkflowAuthority.count() < 1)
        {
            println "init workflowAuthority"
            def a = new WorkflowAuthority(name: 'View')
            a.save flush: true

            a = new WorkflowAuthority(name: 'Edit')
            a.save flush: true

            a = new WorkflowAuthority(name: 'Approval')
            a.save flush: true
        }

        if (RepaymentMethod.count() < 1)
        {
            println "init repaymentMethod"
            def m = new RepaymentMethod(name: '广银联代扣')
            m.save flush: true

            m = new RepaymentMethod(name: '富友代扣')
            m.save flush: true

            m = new RepaymentMethod(name: '自主还款')
            m.save flush: true
        }
        if (ManagerAccountNumber.count() < 1)
        {
            println "init managerAccountNumber"
            def m = new ManagerAccountNumber(name: '外贸555')
            m.save flush: true
            m = new ManagerAccountNumber(name: '中航669')
            m.save flush: true
        }
        if (Subject.count() < 1)
        {
            println "init subject"
            def m = new Subject(name: "应收利息", code: 1001)
            m.save flush: true
            m = new Subject(name: "利息收入", code: 1002)
            m.save flush: true
            m = new Subject(name: "单位活期存款", code: 1003)
            m.save flush: true
        }
        if (CollateralType.count() < 1)
        {
            println "init collateralType"
            def m = new CollateralType(name: "住宅")
            m.save flush: true
            m = new CollateralType(name: "车")
            m.save flush: true
        }
        if (CurrencyType.count() < 1)
        {
            println "init currencyType"
            def m = new CurrencyType(name: "人民币")
            m.save flush: true
            m = new CurrencyType(name: "美元")
            m.save flush: true
            m = new CurrencyType(name: "欧元")
            m.save flush: true
            m = new CurrencyType(name: "港币")
            m.save flush: true
            m = new CurrencyType(name: "英镑")
            m.save flush: true
            m = new CurrencyType(name: "日元")
            m.save flush: true
            m = new CurrencyType(name: "韩元")
            m.save flush: true
        }

        if (CertificateType.count() < 1)
        {
            println "init CertificateType"
            def m = new CertificateType(name: "固定资产")
            m.save flush: true
            m = new CertificateType(name: "学位证")
            m.save flush: true
            m = new CertificateType(name: "文化程度")
            m.save flush: true
            m = new CertificateType(name: "最高学历")
            m.save flush: true
        }
        if (PropertyType.count() < 1)
        {
            println "init propertyType"
            def m = new PropertyType(name: "流动资产")
            m.save flush: true
            m = new PropertyType(name: "长期投资")
            m.save flush: true
            m = new PropertyType(name: "固定资产")
            m.save flush: true
            m = new PropertyType(name: "无形资产")
            m.save flush: true
        }
        if (CollateralSubtype.count() < 4)
        {
            println "init collateralSubtype"
            def at = new CollateralSubtype(name: "大型汽车")
            at.save flush: true

            at = new CollateralSubtype(name: "小型汽车")
            at.save flush: true

            at = new CollateralSubtype(name: "专用汽车")
            at.save flush: true

            at = new CollateralSubtype(name: "特种车")
            at.save flush: true

            at = new CollateralSubtype(name: "有轨电车")
            at.save flush: true

            at = new CollateralSubtype(name: "无轨电车")
            at.save flush: true

            at = new CollateralSubtype(name: "电瓶车")
            at.save flush: true
        }

        if (ProductType.count() < 1)
        {
            println "init productType"
            def type = new ProductType(name: "自有产品")
            type.save()

            type = new ProductType(name: "外部产品")
            type.save()
        }

        if (UserType.count() < 1)
        {
            println "init userType"
            def type = new UserType(name: "机构柜员")
            type.save flush: true

            type = new UserType(name: "商户柜员")
            type.save flush: true

            type = new UserType(name: "渠道柜员")
            type.save flush: true
        }
        if (UserLevel.count() < 1)
        {
            println "init userLevel"
            def level = new UserLevel(name: "一级")
            level.save flush: true

            level = new UserLevel(name: "二级")
            level.save flush: true

            level = new UserLevel(name: "三级")
            level.save flush: true
        }
        if (AccountLevelType.count() < 1)
        {
            println "init accountType"
            def type = new AccountLevelType(name: "机构等级")
            type.save flush: true
        }
        if (!AccountLevelType.findByName("商户等级"))
        {
            println "init accountType"
            def type = new AccountLevelType(name: "商户等级")
            type.save flush: true
        }
        if (AccountLevel.count() < 1)
        {
            println "init accountLevel"
            def type = AccountLevelType.findByName("机构等级")
            def level = new AccountLevel(name: "一级", type: type)
            level.save flush: true
            level = new AccountLevel(name: "二级", type: type)
            level.save flush: true
            level = new AccountLevel(name: "三级", type: type)
            level.save flush: true
        }

        if (!AccountLevel.findByType(AccountLevelType.findByName("商户等级")))
        {
            println "init accountLevel"
            def type = AccountLevelType.findByName("商户等级")
            def level = new AccountLevel(name: "一级经销商", type: type)
            level.save flush: true
            level = new AccountLevel(name: "二级经销商", type: type)
            level.save flush: true
        }

        if (Industry.count() < 1)
        {
            println "init industry"
            def industry = new Industry(name: "金融（银行，保险，证券等）")
            industry.save flush: true
            industry = new Industry(name: "能源（石油，石化，电力等）")
            industry.save flush: true
            industry = new Industry(name: "市政（燃气，供水，公交等）")
            industry.save flush: true
            industry = new Industry(name: "邮电")
            industry.save flush: true
            industry = new Industry(name: "通讯")
            industry.save flush: true
            industry = new Industry(name: "交通")
            industry.save flush: true
            industry = new Industry(name: "广播电视")
            industry.save flush: true
            industry = new Industry(name: "烟草")
            industry.save flush: true
            industry = new Industry(name: "新闻出版")
            industry.save flush: true
            industry = new Industry(name: "文教卫生")
            industry.save flush: true
            industry = new Industry(name: "公务员、行政事业单位客户")
            industry.save flush: true
            industry = new Industry(name: "专业技术人员（有专业资格证书）")
            industry.save flush: true
            industry = new Industry(name: "其他")
            industry.save flush: true
        }
        if (HouseOrigin.count() < 1)
        {
            println "init houseOrigin"
            def h = new HouseOrigin(name: '自置')
            h.save flush: true
            h = new HouseOrigin(name: '按揭')
            h.save flush: true
            h = new HouseOrigin(name: '亲属楼宇')
            h.save flush: true
            h = new HouseOrigin(name: '集体宿舍')
            h.save flush: true
            h = new HouseOrigin(name: '租房')
            h.save flush: true
            h = new HouseOrigin(name: '公有住宅')
            h.save flush: true
            h = new HouseOrigin(name: '其他')
            h.save flush: true
            h = new HouseOrigin(name: '未知')
            h.save flush: true
        }

        if (PaymentMethod.count() < 1)
        {
            println "init paymentMethod"
            def h = new PaymentMethod(name: '受托支付')
            h.save flush: true
            h = new PaymentMethod(name: '自主支付')
            h.save flush: true
        }

        if (GuaranteeType.count() < 1)
        {
            println "init guaranteeType"
            def h = new GuaranteeType(name: '抵押')
            h.save flush: true
            h = new GuaranteeType(name: '信用')
            h.save flush: true
            h = new GuaranteeType(name: '无')
            h.save flush: true
        }

        if (Certificate.count() < 1)
        {
            println "init certificate"
            def type = CertificateType.findByName("文化程度")
            def h = new Certificate(name: '小学')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '初中')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '高中')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '大专')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '本科')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '研究')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '硕士')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '博士')
            h.type = type
            h.save flush: true

            type = CertificateType.findByName("最高学历")
            h = new Certificate(name: '名誉博士')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '博士')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '硕士')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '学士')
            h.type = type
            h.save flush: true
            h = new Certificate(name: '其他')
            h.type = type
            h.save flush: true
        }

        if (ContactProfessionTitle.count() < 1)
        {
            def c = new ContactProfessionTitle(name: '高级')
            c.save flush: true
            c = new ContactProfessionTitle(name: '中级')
            c.save flush: true
            c = new ContactProfessionTitle(name: '初级')
            c.save flush: true
            c = new ContactProfessionTitle(name: '未知')
            c.save flush: true
        }

        if (ContactFeatureCategory.count() < 1)
        {
            def c = new ContactFeatureCategory(name: '公务员、参公人员邮政业')
            c.save flush: true
            c = new ContactFeatureCategory(name: '专业技术人员')
            c.save flush: true
            c = new ContactFeatureCategory(name: '普通工薪阶层件和信息技术服务业')
            c.save flush: true
            c = new ContactFeatureCategory(name: '自雇人士')
            c.save flush: true
            c = new ContactFeatureCategory(name: '军人产业')
            c.save flush: true
            c = new ContactFeatureCategory(name: '要客和商业服务业')
            c.save flush: true
            c = new ContactFeatureCategory(name: '其他研究和技术服务')
            c.save flush: true
        }

        if (ContactFeature.count() < 1)
        {
            def c = ContactFeatureCategory.findByName('公务员、参公人员邮政业')
            def f = new ContactFeature(name: '高级领导境和公共实施管理业')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '中级领导、修理和其他服务业')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '一般职员')
            f.category = c
            f.save flush: true

            c = ContactFeatureCategory.findByName('专业技术人员')
            f = new ContactFeature(name: '现职工作年数>5年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=5年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=3年或4年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=1年或2年AAA')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数<1年或空A')
            f.category = c
            f.save flush: true

            c = ContactFeatureCategory.findByName('普通工薪阶层件和信息技术服务业')
            f = new ContactFeature(name: '现职工作年数>5年结果=A')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=5年结果=B')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=3年或4年C')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=1或2年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数<1年或为空')
            f.category = c
            f.save flush: true

            c = ContactFeatureCategory.findByName('自雇人士')
            f = new ContactFeature(name: '现职工作年数>5年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=5年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=3年或4年')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数=1年或2年AAA')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '现职工作年数<1年或空A')
            f.category = c
            f.save flush: true

            c = ContactFeatureCategory.findByName('军人产业')
            f = new ContactFeature(name: '高级领导会工作')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '中级领导育和娱乐业')
            f.category = c
            f.save flush: true
            f = new ContactFeature(name: '一般职员、社会保障和社会组织')
            f.category = c
            f.save flush: true

            c = ContactFeatureCategory.findByName('要客和商业服务业')
            f = new ContactFeature(name: '其他领导')
            f.category = c
            f.save flush: true

            c = ContactFeatureCategory.findByName('其他研究和技术服务')
            f = new ContactFeature(name: '其他领导')
            f.category = c
            f.save flush: true
        }

        if (AccountEconomyType.count() < 1)
        {
            def c = new AccountEconomyType(name: '政府机关/事业单位')
            c.save flush: true
            c = new AccountEconomyType(name: '国营企业')
            c.save flush: true
            c = new AccountEconomyType(name: '个体经营/自由职业')
            c.save flush: true
            c = new AccountEconomyType(name: '民营企业')
            c.save flush: true
            c = new AccountEconomyType(name: '股份制公司')
            c.save flush: true
            c = new AccountEconomyType(name: '三资企业')
            c.save flush: true
            c = new AccountEconomyType(name: '军队')
            c.save flush: true
            c = new AccountEconomyType(name: '其他')
            c.save flush: true
        }

        if (BankAccountSubType.count() < 1)
        {
            def c = new BankAccountSubType(name: '实体卡')
            c.save flush: true
            c = new BankAccountSubType(name: '数字信用卡')
            c.save flush: true
        }
    }

    def destroy = {}
}
